package com.tourlaid.mamagerment.config

import com.tourlaid.mamagerment.entity.ResponseData
import com.tourlaid.mamagerment.util.TldException
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody

/**
 * Created by xiaoyongge on 2017/7/21.
 */
@ControllerAdvice
//如果返回的为json数据或其它对象，添加该注解
@ResponseBody
class GlobalExceptionHandler {

    @ExceptionHandler(TldException::class)
    fun handleNotFoundException(ex: TldException): ResponseData<String> {
        var responseData = ResponseData(ex.msg.toString(), "")
        return responseData
    }
}